//
//  DCHomeViewController.m
//  Demo
//
//  Created by Kyle on 2022/12/31.
//

#import "DCHomeViewController.h"
#import "DCMineServicesController.h"
#import "DCAuthPhotoController.h"
#import "DCAntuCheckExtExpiredModel.h"
#import "DCAuthBasicInfoController.h"
#import "DCAuthPersonalInfoController.h"
#import "DCAuthContactsController.h"
#import "DCAuthIdentifyController.h"
#import "DCAuthBankCardController.h"

@interface DCHomeViewController ()

@property (nonatomic, strong) UILabel *moneyLabel;

@property (nonatomic, strong)  DCAntuCheckExtExpiredModel *expiredModel;
@end

@implementation DCHomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)configureUI {
    [super configureUI];
    self.navgitBar.hidden = YES;
    self.navgitBar.backBtn.hidden = YES;

////    self.view.backgroundColor = [UIColor redColor];
//    UILabel *titleLabel = [UILabel new];
//    titleLabel.text = @"Efficient Loans";
//    titleLabel.font = DCFont_PF_Medium(30);
//    titleLabel.textColor = [UIColor colorWithString:@"#000000"];
//    [self.view addSubview:titleLabel];
//    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.mas_equalTo(38);
//        make.top.mas_equalTo(kNavHeight);
//    }];
//
//    UIView *colorView = [UIView new];
//    colorView.backgroundColor = [UIColor colorWithString:@"#E1FE97"];
//    colorView.layer.cornerRadius = 8;
//    colorView.layer.masksToBounds = YES;
//    [self.view addSubview:colorView];
//    [colorView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.mas_equalTo(20);
//        make.right.mas_equalTo(-20);
//        make.top.mas_equalTo(titleLabel.mas_bottom).mas_offset(34);
//        make.height.mas_equalTo(200);
//    }];
//
//    UILabel *limitLabel = [UILabel new];
//    limitLabel.text = @"UP TO LIMIT（₦）";
//    limitLabel.font = DCFont_PF_Medium(16);
//    limitLabel.textColor = [UIColor colorWithString:@"#000000"];
//    [colorView addSubview:limitLabel];
//    [limitLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.mas_equalTo(36);
//        make.centerX.mas_equalTo(colorView.mas_centerX);
//    }];
//
//    _moneyLabel = [UILabel new];
//    _moneyLabel.text = @"***";
////    _moneyLabel.backgroundColor = [UIColor redColor];
//    _moneyLabel.font = DCFont_PF_Regular(40);
//    _moneyLabel.textColor = [UIColor colorWithString:@"#1C221B"];
//    [colorView addSubview:_moneyLabel];
//    [_moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.mas_equalTo(limitLabel.mas_bottom).mas_offset(15);
//        make.right.mas_equalTo(colorView.mas_centerX).mas_offset(-5);
//    }];
//
//    UIButton *eyeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
////    eyeBtn.backgroundColor = [UIColor cyanColor];
//    [eyeBtn setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
//    [eyeBtn setImage:[UIImage imageNamed:@"icon-biyanyanjing"] forState:UIControlStateSelected];
//    eyeBtn.selected = YES;
//    [colorView addSubview:eyeBtn];
//    [eyeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.mas_equalTo(_moneyLabel.mas_right).mas_offset(10);
//        make.centerY.mas_equalTo(_moneyLabel.mas_centerY).mas_offset(-3);
//        make.width.height.mas_equalTo(30);
//    }];
//
//    UILabel *approvalLabel = [UILabel new];
//    approvalLabel.text = @"Easy application  |  Automatical approval";
//    approvalLabel.font = DCFont_PF_Regular(12);
//    approvalLabel.textColor = [UIColor colorWithString:@"#658900"];
//    [colorView addSubview:approvalLabel];
//    [approvalLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.centerX.mas_equalTo(colorView.mas_centerX);
//        make.bottom.mas_equalTo(colorView.mas_bottom).mas_offset(-43);
//    }];
//
//    UIButton *applyBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//    applyBtn.backgroundColor = [UIColor colorWithString:@"#1C221B"];
//    [applyBtn setTitle:@"Apply" forState:UIControlStateNormal];
//    applyBtn.titleLabel.font = DCFont_PF_Semibold(15);
//    applyBtn.layer.cornerRadius = 8;
//    applyBtn.layer.masksToBounds = YES;
//    [applyBtn addTarget:self action:@selector(applyAction:) forControlEvents:UIControlEventTouchUpInside];
//    [self.view addSubview:applyBtn];
//    [applyBtn mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.mas_equalTo(20);
//        make.right.mas_equalTo(-20);
//        make.height.mas_equalTo(50);
//        make.top.mas_equalTo(colorView.mas_bottom).mas_offset(34);
//    }];
//
//    UILabel *desLabel = [UILabel new];
//    desLabel.font = DCFont_PF_Semibold(15);
//    desLabel.textColor = [UIColor colorWithString:@"#1C221B"];
//    desLabel.text = @"Only three simple fields are requried";
//    [self.view addSubview:desLabel];
//    [desLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.centerX.mas_equalTo(self.view.mas_centerX);
//        make.top.mas_equalTo(applyBtn.mas_bottom).mas_offset(59);
//    }];
//
//
//    UIButton *personalBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//    [personalBtn setImage:[UIImage imageNamed:@"PersonalLogo"] forState:UIControlStateNormal];
//    [personalBtn addTarget:self action:@selector(personalAtion:) forControlEvents:UIControlEventTouchUpInside];
//    [self.view addSubview:personalBtn];
//    [personalBtn mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.centerX.mas_equalTo(self.view.mas_centerX);
//        make.width.height.mas_equalTo(51);
//        make.top.mas_equalTo(desLabel.mas_bottom).mas_offset(38);
//    }];
//
//    UILabel *personalLabel = [UILabel new];
//    personalLabel.text = @"Personal";
//    personalLabel.font = DCFont_PF_Regular(13);
//    personalLabel.textColor = [UIColor colorWithString:@"#000000"];
//    [self.view addSubview:personalLabel];
//    [personalLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.centerX.mas_equalTo(personalBtn.mas_centerX);
//        make.top.mas_equalTo(personalBtn.mas_bottom).mas_offset(20);
//    }];
//
//    UIButton *basicBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//    [basicBtn setImage:[UIImage imageNamed:@"BasicLogo"] forState:UIControlStateNormal];
//    [basicBtn addTarget:self action:@selector(basicAction:) forControlEvents:UIControlEventTouchUpInside];
//    [self.view addSubview:basicBtn];
//    [basicBtn mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.mas_equalTo(50);
//        make.centerY.width.height.mas_equalTo(personalBtn);
//    }];
//
//    UILabel *basiclLabel = [UILabel new];
//    basiclLabel.text = @"Basic";
//    basiclLabel.font = DCFont_PF_Regular(13);
//    basiclLabel.textColor = [UIColor colorWithString:@"#000000"];
//    [self.view addSubview:basiclLabel];
//    [basiclLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.centerX.mas_equalTo(basicBtn.mas_centerX);
//        make.top.mas_equalTo(basicBtn.mas_bottom).mas_offset(20);
//    }];
//
//    UIButton *contactsBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//    [contactsBtn setImage:[UIImage imageNamed:@"ContactsLogo"] forState:UIControlStateNormal];
//    [contactsBtn addTarget:self action:@selector(contactsAction:) forControlEvents:UIControlEventTouchUpInside];
//    [self.view addSubview:contactsBtn];
//    [contactsBtn mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.right.mas_equalTo(-50);
//        make.centerY.width.height.mas_equalTo(personalBtn);
//    }];
//
//    UILabel *contactslLabel = [UILabel new];
//    contactslLabel.text = @"Contacts";
//    contactslLabel.font = DCFont_PF_Regular(13);
//    contactslLabel.textColor = [UIColor colorWithString:@"#000000"];
//    [self.view addSubview:contactslLabel];
//    [contactslLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.centerX.mas_equalTo(contactsBtn.mas_centerX);
//        make.top.mas_equalTo(contactsBtn.mas_bottom).mas_offset(20);
//    }];
//
//    UIImageView *bgImage = [[UIImageView alloc] init];
////    bgImage.backgroundColor = [UIColor cyanColor];
//    bgImage.image = [UIImage imageNamed:@"homeBG"];
//    CGFloat imageHi = 496.0 / 750 * KScreenWidth;
//    [self.view addSubview:bgImage];
//    [bgImage mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.right.mas_equalTo(0);
//        make.bottom.mas_equalTo(0);
//        make.height.mas_equalTo(imageHi);
//    }];
//
//    UIButton *agreementBtn= [UIButton buttonWithType:UIButtonTypeCustom];
//    [agreementBtn setTitle:@"《Privacy Agreement》" forState:UIControlStateNormal];
//    agreementBtn.titleLabel.font = DCFont_PF_Regular(12);
//    [agreementBtn setTitleColor:[UIColor colorWithString:@"#000000"] forState:UIControlStateNormal];
//    [agreementBtn addTarget:self action:@selector(agreementAction:) forControlEvents:UIControlEventTouchUpInside];
//    [self.view addSubview:agreementBtn];
//    [agreementBtn mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.centerX.mas_equalTo(self.view.mas_centerX);
//        make.bottom.mas_equalTo(-30-kTabbarHeight);
//        make.width.mas_equalTo(130);
//        make.height.mas_equalTo(20);
//    }];
    
}

- (void)getDataFromNet {
    [MBProgressHUD showHUDAddedTo:self.view  animated:YES];
    [DCHttpRequest DCAuthCheckExtExpiredCompleteBlock:^(NSURLSessionDataTask * _Nonnull operation, DCResponseData * _Nonnull responseObject) {
        [MBProgressHUD hideHUDForView:self.view animated:YES];
        if (responseObject.code == 200) {
            DCAntuCheckExtExpiredModel *expiredModel = [DCAntuCheckExtExpiredModel mj_objectWithKeyValues:responseObject.data];
            self.expiredModel = expiredModel;
        } else {
            [DCDCToast toastText:responseObject.message];
        }
    }];
}

- (void)applyAction:(UIButton *)sender {
    [self getNextStep];
    return;
    DCAuthPhotoController *authVC = [[DCAuthPhotoController alloc] init];
    [self.navigationController pushViewController:authVC animated:YES];
}
- (void)getNextStep{
    [DCHttpRequest DCAuthNextStepCompleteBlock:^(NSURLSessionDataTask * _Nonnull operation, DCResponseData * _Nonnull responseObject) {
        if (responseObject.code == 200) {
            DLog(@"%@",responseObject.data);
            if ([responseObject.data isKindOfClass:[NSString class]]) {
                NSString *step = (NSString *)responseObject.data;
                if ([step isEqualToString:@"BASE_INFO"]) {
                    //认证-基础信息
                    DCAuthBasicInfoController *basicInfoVC = [DCAuthBasicInfoController new];
                    [self.navigationController pushViewController:basicInfoVC animated:YES];
                } else if ([step isEqualToString:@"IDENTITY_INFO"]){
                    //认证-KTP
                    DCAuthIdentifyController *idVC = [DCAuthIdentifyController new];
                    [self.navigationController pushViewController:idVC animated:YES];
                } else if ([step isEqualToString:@"LIVENESS_INFO"]){
                    //认证-活体
                    DCAuthPhotoController *photoVC = [DCAuthPhotoController new];
                    [self.navigationController pushViewController:photoVC animated:YES];
                } else if ([step isEqualToString:@"PERSONAL_INFO"]){
                    //认证-个人信息
                    DCAuthPersonalInfoController *personalVC = [DCAuthPersonalInfoController new];
                    [self.navigationController pushViewController:personalVC animated:YES];
                } else if ([step isEqualToString:@"CONTACT_INFO"]){
                    //认证-联系人
                    DCAuthContactsController *contactsVC = [DCAuthContactsController new];
                    [self.navigationController pushViewController:contactsVC animated:YES];
                } else if ([step isEqualToString:@"BANK_INFO"]){
                    //认证-银行卡
                    DCAuthBankCardController *bankVC = [DCAuthBankCardController new];
                    [self.navigationController pushViewController:bankVC animated:YES];
                } else {
                    
                }
            } else {
                
            }
        } else {
            [DCDCToast toastText:responseObject.message];
        }
    }];
}
- (void)basicAction:(UIButton *)sender {
    
}

- (void)personalAtion:(UIButton *)sender {
    
}

- (void)contactsAction:(UIButton *)sender {
    DCMineServicesController *vc = [DCMineServicesController new];
    [self.navigationController pushViewController:vc  animated:YES];
}

- (void)agreementAction:(UIButton *)sender {
    DCWebModel *webInfo = [DCWebModel creatLoanAgreement];
    DCWebViewController *webVC = [[DCWebViewController alloc] initWithModel:webInfo];
    [self.navigationController pushViewController:webVC animated:YES];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
